home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.demo_apps;
-
- import sub_arctic.lib.base_interactor;
- import sub_arctic.lib.manager;
- import sub_arctic.input.simple_press_draggable;
- import sub_arctic.input.event;
- import sub_arctic.output.drawable;
-
- /**
- * This little class implements a draggable separator which can be
- * configured to move only in x or y.
- */
- public class separator extends base_interactor implements simple_press_draggable {
- /* are we x or y? */
- boolean in_x;
-
- /**
- * Create a separator. We assume you are going to constrain the
- * relevant layout attributes other than its width .
- */
- public separator(int w, int h, boolean separate_in_x) {
- super(0,0,w,h);
- in_x=separate_in_x;
- }
- /*
- * Reposition this object, given an event.
- */
- public void reposition(event evt) {
- if (in_x) {
- set_x(x_into_parent(evt.local_x()));
- } else {
- set_y(y_into_parent(evt.local_y()));
- }
- }
- /**
- * Start a drag
- */
- public boolean drag_start(event evt, Object user_info) {
- /* marker needs to be drawn */
- reposition(evt);
- return true;
- }
- /**
- * continue a drag
- */
- public boolean drag_feedback(event evt, Object user_info) {
- reposition(evt);
- return true;
- }
- /**
- * Start a drag
- */
- public boolean drag_end(event evt, Object user_info) {
- reposition(evt);
- return true;
- }
- /**
- * Draw a visual indicator
- */
- public void draw_self_local(drawable d) {
- if (in_x) {
- /* top handle */
- d.fillRect(1,1,w()-2,5);
- /* line in the middle */
- d.drawLine(w()/2,1,w()/2,h()-2);
- /* bottom handle */
- d.fillRect(1,h()-6,w()-2,5);
- } else {
- /* left handle */
- d.fillRect(1,1,5,h()-2);
- d.drawLine(1,h()/2,w()-2,h()/2);
- d.fillRect(w()-6,1,5,h()-2);
- }
- }
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-